package xixirupan.tmgp.tencent.com.vmeim.ui.mine.presenter;

import android.content.Context;
import android.support.v7.widget.LinearSmoothScroller;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;

import org.w3c.dom.Text;

import java.util.List;

import xixirupan.tmgp.tencent.com.vmeim.R;
import xixirupan.tmgp.tencent.com.vmeim.config.URLConfig;
import xixirupan.tmgp.tencent.com.vmeim.ui.mine.model.UserCenterBannersBaen;

/**
 * Created by lenovo on 2016/10/20.
 */

public class GridMineAdapter extends BaseAdapter{
    private List<UserCenterBannersBaen> lists;
    private Context context;
    private LayoutInflater inflater;
    public GridMineAdapter( List<UserCenterBannersBaen> lists,Context context,LayoutInflater inflater) {

        this.lists =lists;
        this.inflater =inflater;
        this.context =context;
        Log.i("GRID===","+========="+lists.size());
    }
     @Override
     public int getCount() {
         return lists.size();
     }

     @Override
     public Object getItem(int position) {
         return lists.get(position);
     }

     @Override
     public long getItemId(int position) {
         return position;
     }

     @Override
     public View getView(int position, View convertView, ViewGroup parent) {
         ViewHolder holder;
         if (convertView ==null)
         {
             convertView =inflater.inflate(R.layout.item_mine_grid,parent,false);
             holder =new ViewHolder(convertView);
             convertView.setTag(holder);
         }else {
             holder = (ViewHolder) convertView.getTag();
         }

         String imgURL = lists.get(position).getImgURL();
         String url = URLConfig.UrlMain.SHOPCAR_IMGBEFORE+imgURL;
         Glide.with(context).load(url).into(holder.imageView);
         holder.textView.setText(lists.get(position).getName());
         return convertView;
     }
    class ViewHolder {
        ImageView imageView;
        TextView textView;
        public  ViewHolder(View view){
            imageView = (ImageView) view.findViewById(R.id.item_grid_img);
            textView = (TextView) view.findViewById(R.id.item_grid_mine);
        }
    }
 }
